//
//  ZZUserInfoCell.m
//  QQplayground
//
//  Created by zhangxy on 2018/6/7.
//  Copyright © 2018年 zhang. All rights reserved.
//

#import "ZZUserInfoCell.h"
#import "ZZHomeTopMenu.h"

@implementation ZZUserInfoCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    _imgAvatar.layer.cornerRadius = _imgAvatar.frame.size.height/2;
    _imgAvatar.layer.masksToBounds = YES;
    
    [self setLayerButton:_btnZan];
    [_btnZan.titleLabel setFont:FontSeventeen];
    [_btnZanCool setImage:[UIImage imageNamed:@"个人页点赞"] forState:0];
    
    [_imgSex setImage:[UIImage imageNamed:@"sex_boy"]];
    
    [_labName setFont:[UIFont boldSystemFontOfSize:21]];
    [_labName setTextColor:UIColorFromRGB(TextWhiteColor)];
    
    [_labLevel setFont:ListElevenFont];
    _labLevel.layer.cornerRadius = 4.0f;
    [_labLevel setTextAlignment:NSTextAlignmentCenter];
    _labLevel.layer.masksToBounds = YES;
    _labLevel.layer.borderColor = UIColorFromRGB(BorderLineColor).CGColor;
    [_labLevel setTextColor:UIColorFromRGB(TextSizeOneColor)];
    _labLevel.layer.borderWidth = 1.0f;
    
    [_btnOpenVip setImage:[UIImage imageNamed:@"开通会员"] forState:0];
    [_btnOpenVip setBackgroundColor:UIColor.clearColor];
    
    [_labDesc setFont:ListElevenFont];
    [_labLabels setFont:ListElevenFont];
    [_labDesc setTextColor:UIColorFromRGB(TextWhiteColor)];
    [_labLabels setTextColor:UIColorFromRGB(TextWhiteColor)];
    
    [self setLayerButton:_btnDS];
    [self setLayerButton:_btnAge];
    [self setLayerButton:_btnCity];
    [self setLayerButton:_btnQQ];
    
    [_labNumber setTextColor:UIColorFromRGB(TextWhiteColor)];
    [_labNumber setFont:FontThirteen];
    
    [_btnZanYellow setImage:[UIImage imageNamed:@"金币"] forState:0];
    [_btnZanYellow setTitleColor:UIColorFromRGB(TextWhiteColor) forState:0];
    [_btnZanYellow.titleLabel setFont:FontThirteen];
    [_btnZanYellow setBackgroundColor:UIColor.clearColor];
    
    
    [_btnZanCool setImage:[UIImage imageNamed:@"钻石"] forState:0];
    [_btnZanCool setTitleColor:UIColorFromRGB(TextWhiteColor) forState:0];
    [_btnZanCool.titleLabel setFont:FontThirteen];
    [_btnZanCool setBackgroundColor:UIColor.clearColor];
    
    
    [_btnTap1 setBackgroundColor:UIColor.clearColor];
    [_btnTap1 setBackgroundImage:[UIImage imageNamed:@"素材"] forState:0];
    [_btnTap1 setTitleColor:UIColorFromRGB(BgTitleColor) forState:0];
    [_btnTap1.titleLabel setFont:ListElevenFont];
    [_btnTap1 setTitle:@"素材" forState:0];
    
    [_btnTap2 setBackgroundColor:UIColor.clearColor];
    [_btnTap2 setBackgroundImage:[UIImage imageNamed:@"帖子"] forState:0];
    [_btnTap2 setTitleColor:UIColorFromRGB(TextWhiteColor) forState:0];
    [_btnTap2.titleLabel setFont:ListElevenFont];
    [_btnTap2 setTitle:@"帖子" forState:0];
    
    [_btnTap3 setBackgroundColor:UIColorFromRGB(BgTitleColor)];
    [_btnTap3 setTitleColor:UIColorFromRGB(TextWhiteColor) forState:0];
    [_btnTap3.titleLabel setFont:ListElevenFont];
    [_btnTap3 setTitle:@"秘密" forState:0];
    
//    CGRect f = _btnTap3.frame;
//    f.origin.x = f.origin.x - f.size.width;
//    [_btnTap2 setFrame:f];
//    f.origin.x = f.origin.x - f.size.width;
//    [_btnTap1 setFrame:f];
}

-(void)dataToView:(User *) user{
    
    [_viewMenus setBackgroundColor:UIColorFromRGB(TextWhiteColor)];
    CGRect f = _viewMenus.frame;
    f.size.width = ScreenWidth;
    _viewMenus.frame = f;
    [ZZViewUtils cutViewRound:_viewMenus radius:10 byRoundingCorners:UIRectCornerTopLeft];
    
    ZZHomeTopMenu *menu = [[ZZHomeTopMenu alloc] initWithFrame:CGRectMake(10, 0, ScreenWidth-20,44) array:@[@"全部",@"头像",@"签名",@"网名",@"图片",@"皮肤"] textColor:UIColorFromRGB(TextSizeOneColor) checkColor:UIColorFromRGB(BgTitleColor) result:^(NSInteger tag, NSString *title) {
        
    }];
    [_viewMenus.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
    [_viewMenus addSubview:menu];
    
    
    [_imgAvatar sd_setImageWithURL:[NSURL URLWithString:user.user_avatar] placeholderImage:[UIImage imageNamed:@"icon_app"]];
    [_labName setText:user.user_name];
    [_labLevel setText:[NSString stringWithFormat:@"Lv %zd",user.group_now_grade]];
    [_btnZan setTitle:user.user_diamond forState:0];
    if(user.user_gender == 1){
        [_imgSex setImage:[UIImage imageNamed:@"sex_boy"]];
    }else{
        [_imgSex setImage:[UIImage imageNamed:@"sex_girl"]];
    }
    [_labDesc setText:user.user_sign];
    [_labLabels setText:user.group_name];
    [_btnDS setTitle:user.user_emotion forState:0];
    [_btnAge setTitle:user.birth_day forState:0];
    [_btnCity setTitle:user.birth_year forState:0];
    [_btnQQ setTitle:[NSString stringWithFormat:@"QQ%@",user.user_qq] forState:0];
    
    [_labNumber setText:[NSString stringWithFormat:@"%@ 关注    %@ 粉丝    %@ 访客    %@ 留言",user.count_follow,user.count_fans,user.count_fav,user.count_follow]];
    
    
    [_btnZanYellow setTitle:user.user_gold forState:0];
    [_btnZanCool setTitle:user.user_diamond forState:0];
    
    [_btnOpenVip setTitle:@"" forState:0];
    if([user.user_blood boolValue]){
        [_btnOpenVip setImage:[UIImage imageNamed:@"开通会员"] forState:0];
    }
    else{
        [_btnOpenVip setImage:[UIImage imageNamed:@"vip"] forState:0];
    }
    
    
    UIImageView *imgLine = [[UIImageView alloc] initWithFrame:CGRectMake(0, self.frame.size.height - 2, ScreenWidth, 2)];
    [imgLine setBackgroundColor:UIColorFromRGB(BgSystemColor)];
    [self addSubview:imgLine];
}

-(void)setLayerButton:(UIButton *) btn{
    [btn setBackgroundColor:UIColorFromRGBAlpha(TextWhiteColor, 0.3)];
    btn.layer.cornerRadius = btn.frame.size.height / 2;
    btn.layer.masksToBounds = YES;
    [btn.titleLabel setFont:ListElevenFont];
    [btn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentCenter];
    [btn setTitleColor:UIColorFromRGB(TextWhiteColor) forState:0];
    [btn setTitleColor:UIColorFromRGB(TextWhiteColor) forState:UIControlStateSelected];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
